@import "~scss/variables";

$sw-field--radio-color-border: $color-gray-300;

.sw-field--radio {
    label ~ .sw-field__radio-group,
    .sw-help-text ~ .sw-field__radio-group {
        margin-top: 12px;
    }

    .sw-field__radio-option {
        display: grid;
        grid-template-columns: 16px 1fr 16px;
        grid-column-gap: 8px;
        margin-bottom: 12px;

        &.is--disabled {
            background-color: $color-gray-50;
        }

        label {
            font-weight: normal;
            font-size: $font-size-xs;
            color: $color-darkgray-200;

            .sw-help-text {
                margin-left: 5px;
            }
        }

        &:hover,
        &:hover > * {
            cursor: pointer;
        }

        &.is--disabled:hover,
        &.is--disabled:hover > * {
            cursor: not-allowed;
        }
    }

    &.sw-field--radio-bordered .sw-field__radio-group {
        border-radius: 4px;
        border: 1px solid $sw-field--radio-color-border;
        padding: 12px 16px;
        margin-bottom: 0;
    }

    .sw-field__radio-input {
        width: 16px;
        height: 16px;
        position: relative;

        input[type="radio"] {
            opacity: 0;
            display: block;
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            border: 0 none;
            background: none;
            -webkit-appearance: none;
            cursor: pointer;
            z-index: 2;

            &:focus-visible {
                outline: revert;
                opacity: 1;
            }

            &:disabled ~ .sw-field__radio-state {
                background: $color-gray-100;
                border-color: $color-gray-300;
                color: lighten($color-darkgray-200, 40%);
            }

            &:checked ~ .sw-field__radio-state {
                border: 5px solid $color-shopware-brand-500;
            }

            &:checked:disabled ~ .sw-field__radio-state {
                background: $color-gray-300;
                border: 1px solid $color-gray-300;
                box-shadow: inset 0 0 0 4px $color-gray-100;
                color: lighten($color-darkgray-200, 40%);
            }
        }

        .sw-field__radio-state {
            position: absolute;
            width: 100%;
            height: 100%;
            z-index: 1;
            background: $color-white;
            color: $color-darkgray-200;
            border: 1px solid $color-gray-300;
            border-radius: 8px;
        }
    }

    &.has--error {
        input[type="radio"]:checked ~ .sw-field__radio-state {
            border: 5px solid $color-crimson-500;
        }

        input[type="radio"]:checked ~ .sw-field__label {
            color: $color-crimson-500;
        }
    }

    &.is--disabled {
        .sw-field__radio-input {
            input[type="radio"] {
                cursor: not-allowed;
            }
        }
    }

    .sw-field__radio-option-label {
        &.error--selection {
            color: $color-crimson-500;
        }
    }

    .sw-field__radio-option-description {
        margin-top: 8px;
        color: $color-darkgray-200;
        font-size: $font-size-xs;
        font-weight: normal;
        line-height: 22px;
    }

    .sw-field__radio-description {
        color: $color-gray-500;
        font-size: $font-size-xs;
        line-height: 22px;
        padding-top: 8px;
    }

    &.sw-field--radio-block {
        .sw-field__label {
            font-size: $font-size-s;
            font-weight: bold;
            line-height: 22px;
            margin-bottom: 20px;
        }

        .sw-field__radio-option {
            transition: border-color ease-in 100ms;
            border: 1px solid $color-gray-200;
            border-radius: $border-radius-default;
            padding: 12px 19px;

            &:not(.is--disabled):hover {
                border-color: $color-shopware-brand-500;
            }
        }

        .sw-field__radio-option label {
            font-size: $font-size-s;
            font-weight: $font-weight-semi-bold;
            line-height: 22px;
            padding-left: 12px;
        }

        .sw-field__radio-input {
            margin-top: 5px;
        }

        .sw-field__radio-option.sw-field__radio-option-checked:not(.is--disabled) {
            background: rgba($color-shopware-brand-500, 0.05);
            border: 1px solid $color-shopware-brand-500;
        }
    }
}
